﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TFit
{
    public partial class AddExercieseDialog : Form
    {
        private Exercise ex_;
        /// <summary>
        /// Конструктор
        /// </summary>
        public AddExercieseDialog()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Получить информацию по новому упражнению
        /// </summary>
        /// <returns>Упражнение</returns>
        public Exercise GetExercise()
        {
            return ex_;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var left = Int32.Parse(leftTextBox.Text);
            var right = Int32.Parse(rightTextBox.Text);
            var date = DateTime.Now;

            ex_ = new Exercise(date, left, right);
            
        }

        private void leftTexBox_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Enter) && (leftTextBox.Text.Length != 0))
            {
                rightTextBox.Focus();
            }
        }

        private void rightTexBox_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Enter) && (rightTextBox.Text.Length != 0))
            {
                button1_Click(null, null);
                this.DialogResult = DialogResult.OK;
            }
        }
    }
}
